Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more robust error bound for the determinant. #5902

Merged
merged 1 commit into from
Mar 8, 2014
Merged

Conversation

andreasnoack
Copy link
Member

The old test for the determinant has caused a lot of trouble. The new test depends on the condition number of the matrix and should therefore work for arbitrary matrices.

I would appreciate if someone with a 32 bit machine could try this out.

Related: #5605, #5874

@rickhg12hs
Copy link
Contributor

Xref #5472 , #5605 , #5874

Looks like your changed test passed, but there are still problems in test/linalg1.jl (and test/linalg2.jl) for 32-bit machines ...

Before applying Pull Request:

$ ./julia -e 'versioninfo()'
Julia Version 0.3.0-prerelease+1692
Commit 736251d* (2014-02-23 06:21 UTC)
Platform Info:
  System: Linux (i686-redhat-linux)
  CPU: Genuine Intel(R) CPU           T2250  @ 1.73GHz
  WORD_SIZE: 32
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm
$ make test-linalg1
    JULIA test/linalg1
     * linalg1
exception on 1: ERROR: assertion failed: |det(capd) - det(apd)| <= 0.002384185791015625
  det(capd) = 1.626428240984628e9
  det(apd) = 1.6264282409980435e9
  difference = 0.01341557502746582 > 0.002384185791015625
 in error at error.jl:22
 in test_approx_eq at test.jl:68
 in anonymous at no file:54
 in runtests at /usr/local/src/julia/julia/test/testdefs.jl:5
 in anonymous at multi.jl:629
 in run_work_thunk at multi.jl:590
 in remotecall_fetch at multi.jl:663
 in remotecall_fetch at multi.jl:678
 in anonymous at task.jl:1320
while loading linalg1.jl, in expression starting on line 23
ERROR: assertion failed: |det(capd) - det(apd)| <= 0.002384185791015625
  det(capd) = 1.626428240984628e9
  det(apd) = 1.6264282409980435e9
  difference = 0.01341557502746582 > 0.002384185791015625
 in error at error.jl:22
 in test_approx_eq at test.jl:68
 in anonymous at no file:54
 in runtests at /usr/local/src/julia/julia/test/testdefs.jl:5
 in anonymous at multi.jl:629
 in run_work_thunk at multi.jl:590
 in remotecall_fetch at multi.jl:663
 in remotecall_fetch at multi.jl:678
 in anonymous at task.jl:1320
while loading linalg1.jl, in expression starting on line 23
while loading /usr/local/src/julia/julia/test/runtests.jl, in expression starting on line 34

make[1]: *** [linalg1] Error 1
make: *** [test-linalg1] Error 2
$ 

After applying PR:

$ git cherry-pick -n 98cc8df
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   test/linalg1.jl
$ make test-linalg1
    JULIA test/linalg1
     * linalg1
exception on 1: ERROR: assertion failed: |apd * inv(capd) - eye(n)| <= 2.220446049250313e-10
  apd * inv(capd) = .9999999999690772   15279510989785194e-26   3637978807091713e-26    -8185452315956354e-27   -4729372449219227e-26   18189894035458565e-27   12732925824820995e-26   -9094947017729282e-27   -21827872842550278e-27  -6821210263296962e-28
-11823431123048067e-27  1.0000000002073648  -15643308870494366e-26  28194335754960775e-27   16370904631912708e-26   3637978807091713e-27    14551915228366852e-26   -18189894035458565e-28  -54569682106375694e-27  6821210263296962e-27
-54569682106375694e-27  1673470251262188e-25    1.000000000010914   9094947017729282e-27    5820766091346741e-26    -836735125631094e-25    9094947017729282e-26    -54569682106375694e-27  -14915713109076023e-26  54569682106375694e-28
-54569682106375694e-28  13460521586239338e-26   -29103830456733704e-27  .9999999999818101   9822542779147625e-26    -6184563972055912e-26   6184563972055912e-26    -4001776687800884e-26   -2546585164964199e-26   -13642420526593924e-28
-5820766091346741e-26   2837623469531536e-25    -21827872842550278e-27  7275957614183426e-27    1.0000000000800355  -54569682106375694e-27  1418811734765768e-25    -29103830456733704e-27  -15643308870494366e-26  22737367544323206e-28
-4547473508864641e-26   11641532182693481e-26   -9458744898438454e-26   8185452315956354e-27    6548361852765083e-26    .9999999999436113   1127773430198431e-25    -27284841053187847e-27  -14551915228366852e-26  5229594535194337e-27
-48203219193965197e-27  17462298274040222e-26   5093170329928398e-26    2000888343900442e-26    12005330063402653e-26   -10550138540565968e-26  1.0000000000363798  -29103830456733704e-27  -5820766091346741e-26   6821210263296962e-28
-4729372449219227e-26   23283064365386963e-26   -54569682106375694e-27  18189894035458565e-27   12005330063402653e-26   -12732925824820995e-26  1964508555829525e-25    .9999999998981366   -1382431946694851e-25   8412825991399586e-27
-6002665031701326e-26   2255546860396862e-25    -1127773430198431e-25   54569682106375694e-28   16370904631912708e-26   -9276845958083868e-26   1000444171950221e-25    -8003553375601768e-26   .999999999836291    12732925824820995e-27
-5093170329928398e-26   2255546860396862e-25    29103830456733704e-27   -2091837814077735e-26   7639755494892597e-26    -3637978807091713e-27   6548361852765083e-26    -16370904631912708e-27  -5093170329928398e-26   .9999999999947704

  eye(n) = 1    0   0   0   0   0   0   0   0   0
0   1   0   0   0   0   0   0   0   0
0   0   1   0   0   0   0   0   0   0
0   0   0   1   0   0   0   0   0   0
0   0   0   0   1   0   0   0   0   0
0   0   0   0   0   1   0   0   0   0
0   0   0   0   0   0   1   0   0   0
0   0   0   0   0   0   0   1   0   0
0   0   0   0   0   0   0   0   1   0
0   0   0   0   0   0   0   0   0   1

  difference = 2.837623469531536e-10 > 2.220446049250313e-10
 in error at error.jl:22
 in test_approx_eq at test.jl:68
 in anonymous at no file:54
 in runtests at /usr/local/src/julia/julia/test/testdefs.jl:5
 in anonymous at multi.jl:629
 in run_work_thunk at multi.jl:590
 in remotecall_fetch at multi.jl:663
 in remotecall_fetch at multi.jl:678
 in anonymous at task.jl:1320
while loading linalg1.jl, in expression starting on line 23
ERROR: assertion failed: |apd * inv(capd) - eye(n)| <= 2.220446049250313e-10
  apd * inv(capd) = .9999999999690772   15279510989785194e-26   3637978807091713e-26    -8185452315956354e-27   -4729372449219227e-26   18189894035458565e-27   12732925824820995e-26   -9094947017729282e-27   -21827872842550278e-27  -6821210263296962e-28
-11823431123048067e-27  1.0000000002073648  -15643308870494366e-26  28194335754960775e-27   16370904631912708e-26   3637978807091713e-27    14551915228366852e-26   -18189894035458565e-28  -54569682106375694e-27  6821210263296962e-27
-54569682106375694e-27  1673470251262188e-25    1.000000000010914   9094947017729282e-27    5820766091346741e-26    -836735125631094e-25    9094947017729282e-26    -54569682106375694e-27  -14915713109076023e-26  54569682106375694e-28
-54569682106375694e-28  13460521586239338e-26   -29103830456733704e-27  .9999999999818101   9822542779147625e-26    -6184563972055912e-26   6184563972055912e-26    -4001776687800884e-26   -2546585164964199e-26   -13642420526593924e-28
-5820766091346741e-26   2837623469531536e-25    -21827872842550278e-27  7275957614183426e-27    1.0000000000800355  -54569682106375694e-27  1418811734765768e-25    -29103830456733704e-27  -15643308870494366e-26  22737367544323206e-28
-4547473508864641e-26   11641532182693481e-26   -9458744898438454e-26   8185452315956354e-27    6548361852765083e-26    .9999999999436113   1127773430198431e-25    -27284841053187847e-27  -14551915228366852e-26  5229594535194337e-27
-48203219193965197e-27  17462298274040222e-26   5093170329928398e-26    2000888343900442e-26    12005330063402653e-26   -10550138540565968e-26  1.0000000000363798  -29103830456733704e-27  -5820766091346741e-26   6821210263296962e-28
-4729372449219227e-26   23283064365386963e-26   -54569682106375694e-27  18189894035458565e-27   12005330063402653e-26   -12732925824820995e-26  1964508555829525e-25    .9999999998981366   -1382431946694851e-25   8412825991399586e-27
-6002665031701326e-26   2255546860396862e-25    -1127773430198431e-25   54569682106375694e-28   16370904631912708e-26   -9276845958083868e-26   1000444171950221e-25    -8003553375601768e-26   .999999999836291    12732925824820995e-27
-5093170329928398e-26   2255546860396862e-25    29103830456733704e-27   -2091837814077735e-26   7639755494892597e-26    -3637978807091713e-27   6548361852765083e-26    -16370904631912708e-27  -5093170329928398e-26   .9999999999947704

  eye(n) = 1    0   0   0   0   0   0   0   0   0
0   1   0   0   0   0   0   0   0   0
0   0   1   0   0   0   0   0   0   0
0   0   0   1   0   0   0   0   0   0
0   0   0   0   1   0   0   0   0   0
0   0   0   0   0   1   0   0   0   0
0   0   0   0   0   0   1   0   0   0
0   0   0   0   0   0   0   1   0   0
0   0   0   0   0   0   0   0   1   0
0   0   0   0   0   0   0   0   0   1

  difference = 2.837623469531536e-10 > 2.220446049250313e-10
 in error at error.jl:22
 in test_approx_eq at test.jl:68
 in anonymous at no file:54
 in runtests at /usr/local/src/julia/julia/test/testdefs.jl:5
 in anonymous at multi.jl:629
 in run_work_thunk at multi.jl:590
 in remotecall_fetch at multi.jl:663
 in remotecall_fetch at multi.jl:678
 in anonymous at task.jl:1320
while loading linalg1.jl, in expression starting on line 23
while loading /usr/local/src/julia/julia/test/runtests.jl, in expression starting on line 34

make[1]: *** [linalg1] Error 1
make: *** [test-linalg1] Error 2
$ 

@andreasnoack
Copy link
Member Author

I have added more condition number aware error bands and tried the tests on a 32 bit VB. The Woodbury test is now failing on 32 bit and is complicated solve. I haven't found a good error bound yet for that.

@tkelman tkelman mentioned this pull request Mar 7, 2014
…nalg tests. Add fallback condition number method.
@andreasnoack
Copy link
Member Author

@rickhg12hs I have updated this and now the tests pass on my 32 bit virtual box. Can you try it out on your machine?

@rickhg12hs
Copy link
Contributor

Xref: #5472
Holy Mackerel! First time make test-linalg has passed since sometime in January!

$ patch -p1 -i ../tmp/5902.patch 
patching file base/linalg/factorization.jl
patching file test/linalg1.jl
patching file test/linalg2.jl
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   base/linalg/factorization.jl
#   modified:   test/linalg1.jl
#   modified:   test/linalg2.jl
#
no changes added to commit (use "git add" and/or "git commit -a")
$ make -j2 && make -j2 debug && make
$ ./julia -e 'versioninfo()'
Julia Version 0.3.0-prerelease+1908
Commit e7c2f99* (2014-03-08 04:43 UTC)
Platform Info:
  System: Linux (i686-redhat-linux)
  CPU: Genuine Intel(R) CPU           T2250  @ 1.73GHz
  WORD_SIZE: 32
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm
$ make test-linalg
    JULIA test/linalg
    From worker 3:       * linalg2
    From worker 2:       * linalg1
    SUCCESS
$ 

@andreasnoack
Copy link
Member Author

@jiahao It works and is better than hardcoded values, but it still needs improvement. However, it makes the tests pass on 32 bit systems so I think it would be good to get merged. Are you okay with that?

@StefanKarpinski
Copy link
Sponsor Member

Yes, please!

jiahao added a commit that referenced this pull request Mar 8, 2014
A more robust error bound for the determinant.
@jiahao jiahao merged commit 9d108f4 into master Mar 8, 2014
@jiahao
Copy link
Member

jiahao commented Mar 8, 2014

Good enough for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants